package com.maker.config;

import com.maker.core.WxPayTemplate;
import com.maker.utils.HttpClientFactory;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.RSAPublicKeyConfig;
import com.wechat.pay.java.service.partnerpayments.nativepay.NativePayService;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@EnableConfigurationProperties(WxPayProperties.class)
@Configuration
public class WxAutoConfiguration {
    /**


    @Bean
    public CloseableHttpClient httpClient(WxPayProperties wxPayProperties) {
        //TODO 加载平台证书（mchId：商户号，mchSerialNo：商户证书序列号，apiV3Key:v3密钥）
        Config config =
                new RSAPublicKeyConfig.Builder()
                        .merchantId(wxPayProperties.getMchId())
                        .privateKey(wxPayProperties.getPrivateKey())
                        .publicKey(wxPayProperties.getPublicKey())
//                        .privateKeyFromPath(wxPayProperties.getPrivateKeyPath())
//                        .publicKeyFromPath(wxPayProperties.getPublicKeyPath())
                        .publicKeyId(wxPayProperties.getPublicKeyId())
                        .merchantSerialNumber(wxPayProperties.getMchSerialNo())
                        .apiV3Key(wxPayProperties.getApiV3Key())
                        .build();
        CloseableHttpClient httpClient = HttpClientFactory.createHttpClient(config);
        return httpClient;
    }


    @Bean
    public WxPayTemplate wxPayTemplate(WxPayProperties wxPayProperties, CloseableHttpClient httpClient){
        return new WxPayTemplate(wxPayProperties,httpClient);
    }
     */
}
